<?php
	class Content{

		function __construct(){
		}

		function __destruct(){
		}

		public function getPageContent($id=NULL){
			$where = " WHERE pc.status != '2' ";
			if($id)	$where.=" AND pc.id = ".$id;
			
			$qry = "SELECT pc.* FROM page_content pc ".$where. " ORDER BY pc.id DESC ";
			
			$rs = MyDB::$db->Execute($qry);
			$page_content = array();
			while ($row=$rs->fetchRow()) {
				$page_content[]=$row;
			}
			return $page_content;
		}
		
		public function getNewsList($id=NULL){
			if($id)	$where =" AND n.id = ".$id;
			
			$qry = "SELECT n.*, sm.name as entity_name FROM news as n 
			LEFT JOIN services_master as sm ON sm.id = n.entity_id 
			WHERE n.status != '2' AND n.entity_type = '1'". $where. 

			" UNION		

			SELECT n.*, p.product_name as entity_name FROM news as n 
			LEFT JOIN product AS p ON p.id = n.entity_id 
			WHERE n.status != '2' AND n.entity_type = '2'". $where;

			
			$rs = MyDB::$db->Execute($qry);
			$news = array();
			while ($row=$rs->fetchRow()) {
				$news[]=$row;
			}
			return $news;
		}
		
		function getContent($id = ''){
			return MyDB::$db->getRow("SELECT * FROM page_content where slug ='".$id."'");
		}
	}	
?>